﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Water.Web.Controls.Office.Excel.Util
{
    public class Label
    {
        /// <summary>
        /// 输出创建label的VBScript语句
        /// </summary>
        /// <param name="range">Excel.Util Range</param>
        /// <param name="title">标题</param>
        /// <param name="style">Range样式</param>
        /// <returns>创建label的VBScript语句</returns>
        public static string CreateExcelLabel(string range, string title, string style)
        {
            string _excelLabel = "\nExcel.ActiveSheet." + range + ".Formula=\"" + title.Replace("\"", "\"\"")+"\"\n";
            if (!string.IsNullOrEmpty(style))
            {
                _excelLabel += "Excel.ActiveSheet." + range + ".Style = \"" + style + "\"\n";
                _excelLabel += "Excel.ActiveSheet." + range + ".EntireRow.AutoFit\n";
            }
            return _excelLabel;
        }
        /// <summary>
        /// 输出创建label的VBScript语句
        /// </summary>
        /// <param name="range">Excel.Util Range</param>
        /// <param name="title">标题</param>
        /// <returns>创建label的VBScript语句</returns>
        public static string CreateExcelLabel(string range, string title)
        {
            return CreateExcelLabel(range, title, null);
        }

    }
}
